<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			function fun() {
				let t1 = document.querySelector("#t1").value
				if (t1 == "") {
					document.querySelector("#s1").innerHTML = "姓名不能为空"
					return false
				} else {
					document.querySelector("#s1").innerHTML = "通过"
				}
				let t2 = document.querySelector("#t2").value
				if (t2.length < 6) {
					document.querySelector("#s2").innerHTML = "密码长度不足"
					return false
				} else {
					document.querySelector("#s2").innerHTML = "通过"
				}
				let t3 = document.querySelector("#t3").value
				if (isNaN(t3) || t3 <= 0 || t3 >= 150) {
					document.querySelector("#s3").innerHTML = "年龄不合法"
					return false
				} else {
					document.querySelector("#s3").innerHTML = "通过"
				}
				let t4 = document.querySelector("#t4").value
				let reg = /^1\d{10}$/
				if (!reg.test(t4)) {
					document.querySelector("#s4").innerHTML = "手机号错误"
					return false
				} else {
					document.querySelector("#s4").innerHTML = "通过"
				}
				return false //方便测试

			}
		</script>
	</head>
	<body>
		<form action="" method="post" onsubmit="return fun()">
			姓名：<input type="text" id="t1" />
			<span id="s1"></span><br>
			密码：<input type="password" id="t2" />
			<span id="s2"></span><br>
			年龄：<input type="text" id="t3" />
			<span id="s3"></span><br>
			手机：<input type="text" id="t4" />
			<span id="s4"></span><br>
			<input type="submit" value="提交" />
		</form>
	</body>
</html>
